#include <stdio.h>
#include <stdlib.h>
int int_cmp(const void *a,const void*b)
{
	return *(int*)a<*(int*)b;
}
int thirdMax(int* nums, int numsSize) {
    qsort(nums,numsSize,sizeof(nums[0]),int_cmp);
    int count=0;
    int index=1;
    int num=nums[0];
    while(index<numsSize)
    {
    	if(nums[index]!=num)
    	{
    		num=nums[index];
    		count++;
		}
		index++;
		if(count==2)
		{
			return num;
		}
	}
	return nums[0];
}

int main()
{
	int nums[]={ 8,6,4,5};
	int numsSize=sizeof(nums)/sizeof(nums[0]);
	int ret1=thirdMax(nums,numsSize);
printf("%d\n",ret1);
	return 0;
}
